package com.drugStorage.spring.ServiceImpl;

import java.util.List;

import com.drugStorage.domain.BuyList;
import com.drugStorage.domain.BuyPlan;
import com.drugStorage.hibernate.dao.BuyPlanDao;
import com.drugStorage.spring.service.BuyPlanService;

public class BuyPlanServiceImpl implements BuyPlanService {
	private BuyPlanDao buyPlanDao;

	public BuyPlanDao getBuyPlanDao() {
		return buyPlanDao;
	}

	public void setBuyPlanDao(BuyPlanDao buyPlanDao) {
		this.buyPlanDao = buyPlanDao;
	}

	public void AddBuyListToBuyPlan(int BuyPlanid, BuyList buyList) {
		BuyPlan buyPlan = buyPlanDao.getBuyPlanById(BuyPlanid);
		buyList.setBuyPlan(buyPlan);
		buyPlanDao.AddBuyListByPlanId(buyList);

	}

	public void delBuyPlan(BuyPlan buyPlan) {
		buyPlanDao.DelBuyPlan(buyPlan);

	}

	public List<BuyList> getAllListByPlanId(int buyPlanid) {
	
		return buyPlanDao.getBuyListByPlanId(buyPlanid);
	}

	public List<BuyPlan> getAllPlans() {
		
		return buyPlanDao.getAllBuyPlan();
	}

	public List<BuyPlan> getPlanNotChecked(int checked) {
	
		return buyPlanDao.getBuyPlanListByIschecked(checked);
	}

	public void saveBuyPlan(BuyPlan buyPlan) {
		buyPlanDao.SaveBuyPlan(buyPlan);

	}

	public void updateBuyPlan(BuyPlan buyPlan) {
	   buyPlanDao.UpdateBuyPlan(buyPlan);

	}

	public void CheckBuyPlan(BuyPlan buyPlan) {
	      buyPlan.setIsChecked(1);
	      buyPlanDao.UpdateBuyPlan(buyPlan);
		
	}

	public BuyPlan getBuyPlan(int Bid) {
		
		return buyPlanDao.getBuyPlanById(Bid);
	}

}
